﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public class InvokeHelper
    {
        private readonly SynchronizationContext _Context;
        public InvokeHelper(SynchronizationContext context)
        {
            _Context = context;
        }
        public void Invoke(Control control, string text)
        {
            _Context.Post(state =>
            {
                control.Text = (string)state;
            }, text);
        }
    }
}
